#!/usr/bin/env bash
#Use this script to update the ast398 svn hosted by google

#get the repo name
if [[ -z $1 ]]; then
	SVN_REPO="ast398"
else
	SVN_REPO="$1"
fi

#The google URL
SVN_URL="ast398.googlecode.com/svn/trunk/"

#The checkout username
SVN_USER="josh.albert@hotmail.com"

#The checkout password
SVN_PASS="VT3tW6yX3aU6"

#check to see if we are root
if (( EUID != 0 )); then
	echo You are not root
else
	echo You are root
fi

#the path where svn folder is on the local filesystem
SVN_PATH=~/svn/

#check to make sure SVNPATH exists
if [[ ! -d "$SVN_PATH" ]]; then
	echo The path to local svn \($SVN_PATH\) does not exist
	echo Exitting...
	exit 1
fi

#the current path so that we can change back later
CURPATH=$(pwd)

#go to svn path
cd $SVNPATH

#do the checkout
echo Doing the checkout...
svn checkout https://$SVN_URL $SVN_REPO --username $SVN_USER --password $SVN_PASS

cd $CURPATH

echo Done.
exit 0
